package com.mo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.remoting.caucho.HessianServiceExporter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.mo.config.properties.HessianProperties;
import com.mo.config.properties.JwtProperties;
import com.mo.search.service.ISearchMixedService;
import com.mo.search.service.IWriteMixedService;

/**
 * mo Web程序启动类
 *
 * @author chenxiaodong
 * @date 2018-05-21 9:43
 */
public class HessianServletInitializer extends WebMvcConfigurerAdapter {

    @Autowired
    private JwtProperties jwtProperties;
	@Autowired
	private HessianProperties hessianProperties;
// ----------TV端TV端TV端TV端TV端TV端-------------------------------------------------------------------------------------------------------
	
    /*@Bean
   	public MoHessianProxyFactoryBean integralService() {
   	    MoHessianProxyFactoryBean factory = new MoHessianProxyFactoryBean( jwtProperties.getMd5Key(),jwtProperties.getSecret(),jwtProperties.getExpiration());
   	    factory.setServiceUrl(hessianProperties.getTvHessianUrl()+"/hessian/integralService");
   	    factory.setServiceInterface(IIntegralService.class);
   	    return factory;
   	}*/
   
   
// ----------手机端手机端手机端手机端手机端---------------------------------------手机端-------------------------------------------------------------------
    /*@Bean
    public MoHessianProxyFactoryBean muserService() {
    	MoHessianProxyFactoryBean factory = new MoHessianProxyFactoryBean( jwtProperties.getMd5Key(),jwtProperties.getSecret(),jwtProperties.getExpiration());
		factory.setServiceUrl(hessianProperties.getMobileHessianUrl()+"/hessian/muserService");
		factory.setServiceInterface(IMuserService.class);
		return factory;
    }*/
   
 // ---------搜索引擎-生产者-搜索引擎-生产者-搜索引擎-生产者-搜索引擎-生产者---------------------------------------手机端-------------------------------------------------------------------

    @Autowired
    private ISearchMixedService searchMixedService;
    @Bean(name = "/hessian/searchMixedService")
    public HessianServiceExporter searchMixedService() {
      HessianServiceExporter exporter = new HessianServiceExporter();
      exporter.setService(searchMixedService);
      exporter.setServiceInterface(ISearchMixedService.class);
      return exporter;
    }
    @Autowired
    private IWriteMixedService writeMixedService;
    @Bean(name = "/hessian/writeMixedService")
    public HessianServiceExporter writeMixedService() {
      HessianServiceExporter exporter = new HessianServiceExporter();
      exporter.setService(writeMixedService);
      exporter.setServiceInterface(IWriteMixedService.class);
      return exporter;
    }
    
}
